﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FileMonitor.Service.ProcessMonitor.Model;
using FileInfo = FileMonitor.Service.ProcessMonitor.Model.FileInfo;
using System.IO;
namespace FileMonitor.Service.ProcessMonitor.Util
{
    public class FileUtil
    {
        public static FileInfo GenerateFileInfo(string fullFilePath, FileState fileState)
        {
            try
            {
                string fileName = Path.GetFileName(fullFilePath);
                FileInfo fi = new FileInfo(fileName);
                System.IO.FileInfo ioFi = new System.IO.FileInfo(fullFilePath);
                fi.Size = ioFi.Length;
                fi.CreatedDate = ioFi.CreationTime;
                fi.ProcessedDate = System.DateTime.Now;
                fi.State = fileState;
                fi.FullPath = fullFilePath;

                return fi;
            }
            catch (System.IO.FileNotFoundException ex)
            {
                return null;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
